package com.android.clinic.app.http;

import com.android.clinic.app.entity.AppointInfo;
import com.android.clinic.app.entity.BannerInfo;
import com.android.clinic.app.entity.DepartmentInfo;
import com.android.clinic.app.entity.DiagnosedInfo;
import com.android.clinic.app.entity.DoctorInfo;
import com.android.clinic.app.entity.DoctorListInfo;
import com.android.clinic.app.entity.DuePriceInfo;
import com.android.clinic.app.entity.ReportInfo;
import com.android.clinic.app.entity.UserInfo;
import com.android.clinic.app.http.base.BaseResponse;

import java.util.List;

import io.reactivex.Observable;
import okhttp3.MultipartBody;
import okhttp3.RequestBody;
import okhttp3.ResponseBody;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.Headers;
import retrofit2.http.Multipart;
import retrofit2.http.POST;
import retrofit2.http.Part;
import retrofit2.http.Path;
import retrofit2.http.Query;
import retrofit2.http.Url;

/**
 * Created by cheng on 2018/2/7.
 */
public interface HttpService {

    /**
     * 首页轮播图
     * @return
     */
    @GET("carousel/to_list_all")
    Observable<BaseResponse<List<BannerInfo>>> getBannerListAll();

    /**
     * 首页科室分类
     * @return
     */
    @GET("departmentRest/list/topDepart")
    Observable<BaseResponse<List<DepartmentInfo>>> getDepartment();

    /**
     * 获取科室二级分类
     * @return
     */
    @FormUrlEncoded
    @POST("departmentRest/list/secondDepart")
    Observable<BaseResponse<List<DepartmentInfo>>> getSecondDepartment(@Field("topDepartId") String topDepartId);

    /**
     * 首页名医推荐
     * @return
     */
    @GET("doctorRest/list/toHome")
    Observable<BaseResponse<List<DoctorInfo>>> getHomeDoctor();

    /**
     * 就诊动态(暂无使用)
     * @return
     */
    @GET("doctorRest/get/doctorDynamic")
    Observable<BaseResponse<String>> getDoctorDynamic();

    /**
     * 名医列表
     * @return
     */
    @GET("doctorRest/list/all")
    Observable<BaseResponse<DoctorListInfo>> getListAllDoctor(@Query("deptName") String deptName, @Query("hospital") String hospital,
                                                              @Query("pageSize") int pageSize, @Query("pageNum") int pageNum);

    /**
     * 名医详情
     * @param doctorId
     * @return
     */
    @GET("doctorRest/get/doctorInfo")
    Observable<BaseResponse<DoctorInfo>> getDoctorDetail(@Query("doctorId") String doctorId);

    /**
     * 获取当前医生是否被关注
     * @param doctorId
     * @param userId
     * @return
     */
    @GET("followRest/list/follow")
    Observable<BaseResponse<String>> getFollow(@Query("doctorId") String doctorId, @Query("userId") String userId);

    /**
     * 添加关注
     * @param doctorId
     * @param userId
     * @return
     */
    @GET("followRest/add/follow")
    Observable<BaseResponse<String>> addFollow(@Query("doctorId") String doctorId, @Query("userId") String userId);

    /**
     * 出诊时间(暂无使用)
     * @param doctorId
     * @return
     */
    @GET("doctorRest/get/Scheduling")
    Observable<BaseResponse<DiagnosedInfo>> getScheduling(@Query("doctorId") String doctorId);

    /**
     * 搜索关键字
     * @param name
     * @param pageSize
     * @param pageNum
     * @return
     */
    @GET("doctorRest/list/search")
    Observable<BaseResponse<DoctorListInfo>> getListSearch(@Query("name") String name, @Query("pageSize") int pageSize,
                                                     @Query("pageNum") int pageNum);

    /**
     * 获取短信验证码
     * @param mobile
     * @return
     */
    @FormUrlEncoded
    @POST("smsRest/send/message")
    Observable<BaseResponse<String>> getSmsCode(@Field("mobile") String mobile);

    /**
     * 登录
     * @param mobile
     * @param code
     * @return
     */
    @FormUrlEncoded
    @POST("userRest/login/app")
    Call<ResponseBody> login(@Field("mobile") String mobile, @Field("code") String code,
                                  @Field("memberId") String memberId, @Field("password") String password);

//    Observable<BaseResponse<UserInfo>> login(@Field("mobile") String mobile, @Field("code") String code,
//                                             @Field("memberId") String memberId, @Field("password") String password);

    /**
     * 忘记密码
     * @param json
     * @return
     */
    @Headers("Content-Type: application/json")
    @POST("user_password/reset")
    Observable<BaseResponse<String>> resetPassword(@Body RequestBody json);

    /**
     * 忘记密码 - 发送短信验证码
     * @param mobile
     * @return
     */
    @GET("user_password/send_message/{mobile}")
    Observable<BaseResponse<String>> resetSendCodeByMobile(@Path("mobile") String mobile);

    /**
     * 获取用户信息
     * @param userId
     * @return
     */
    @FormUrlEncoded
    @POST("userRest/get/userInfo")
    Observable<BaseResponse<UserInfo>> getUserInfo(@Field("userId") String userId);

    /**
     * 绑定VIP
     * @param userId
     * @param mobile
     * @param memberId
     * @return
     */
    @FormUrlEncoded
    @POST("userRest/bindVIP")
    Observable<BaseResponse<String>> bindVip(@Field("userId") String userId, @Field("mobile") String mobile,
                                             @Field("memberId") String memberId, @Field("password") String password);

    /**
     * 获取付费价格
     * @return
     */
    @GET("user/due/get_due_price")
    Observable<BaseResponse<List<DuePriceInfo>>> getDuePrice();

    /**
     * 会员过期
     * @param id
     * @param days
     * @return
     */
    @GET("user/due/to_recharge/{id}/{alwaysFree}/{days}")
    Observable<BaseResponse<String>> rechargeVip(@Path("id") String id, @Path("alwaysFree") Integer alwaysFree, @Path("days") Integer days);

    /**
     * 更新用户性别
     * @param userId
     * @param gender
     * @return
     */
    @FormUrlEncoded
    @POST("userRest/update/gender")
    Observable<BaseResponse<String>> updateGender(@Field("userId") String userId, @Field("gender") String gender);

    /**
     * 更新出生日期(暂无使用)
     * @param userId
     * @param birthday
     * @return
     */
    @FormUrlEncoded
    @POST("userRest/update/birthday")
    Observable<BaseResponse<String>> updateBirthday(@Field("userId") String userId, @Field("birthday") String birthday);

    /**
     * 更新昵称
     * @param userId
     * @param nickName
     * @return
     */
    @FormUrlEncoded
    @POST("userRest/update/name")
    Observable<BaseResponse<String>> updateRealName(@Field("userId") String userId, @Field("name") String nickName);

    /**
     * 更新身份证件号
     * @param userId
     * @param idCard
     * @return
     */
    @FormUrlEncoded
    @POST("userRest/update/id_card")
    Observable<BaseResponse<String>> updateIdCard(@Field("userId") String userId, @Field("idCard") String idCard);

    /**
     * 更新职业
     * @param userId
     * @param professional
     * @return
     */
    @FormUrlEncoded
    @POST("userRest/update/professional")
    Observable<BaseResponse<String>> updateProfessional(@Field("userId") String userId, @Field("professional") String professional);

    /**
     * 更新婚育情况
     * @param userId
     * @param marriage
     * @return
     */
    @FormUrlEncoded
    @POST("userRest/update/marriage")
    Observable<BaseResponse<String>> updateMarriage(@Field("userId") String userId, @Field("marriage") int marriage);


    /**
     * 更新生活习惯
     * @param userId
     * @param liveHabit
     * @return
     */
    @FormUrlEncoded
    @POST("userRest/update/liveHabit")
    Observable<BaseResponse<String>> updateLiveHabit(@Field("userId") String userId, @Field("liveHabit") String liveHabit);

    /**
     * 更新过敏史
     * @param userId
     * @param allergy
     * @return
     */
    @FormUrlEncoded
    @POST("userRest/update/allergy")
    Observable<BaseResponse<String>> updateAllergy(@Field("userId") String userId, @Field("allergy") String allergy);

    /**
     * 更新既往病史
     * @param userId
     * @param history
     * @return
     */
    @FormUrlEncoded
    @POST("userRest/update/history")
    Observable<BaseResponse<String>> updateHistory(@Field("userId") String userId, @Field("history ") String history );

    /**
     * 更新用户头像
     * @param userId
     * @param imgUrl
     * @return
     */
    @FormUrlEncoded
    @POST("userRest/update/image")
    Observable<BaseResponse<String>> updateHeadImg(@Field("userId") String userId, @Field("imgUrl") String imgUrl);

    /**
     * 添加收货地址(购买会员卡)
     * @param name
     * @param address
     * @param mobile
     * @param totalFee
     * @param body
     * @param subject
     * @return
     */
    @FormUrlEncoded
    @POST("userRest/add/address")
    Observable<BaseResponse<String>> addAddress(@Field("name") String name, @Field("address") String address,
                                                @Field("mobile") String mobile, @Field("totalFee") String totalFee,
                                                @Field("body") String body, @Field("subject") String subject);

    /**
     * 多张图片
     * @param partList
     * @return
     */
    @Multipart
    @POST("upload")
    Observable<BaseResponse<String>> uploadMultipleTypeFile(@Part List<MultipartBody.Part> partList);

    /**
     * 单张图片
     * @param file
     * @return
     */
    @Multipart
    @POST("upload")
    Observable<BaseResponse<String>> uploadSingleTypeFile(@Part MultipartBody.Part file);

    /**
     * 支付宝支付
     * @param body
     * @param subject
     * @param totalFee
     * @param userId
     * @return
     */
    @FormUrlEncoded
    @POST("alipay/app/body")
    Observable<BaseResponse<String>> aliPay(@Field("body") String body, @Field("subject") String subject,
                                    @Field("totalFee") String totalFee, @Field("userId") String userId);

    /**
     * 微信支付
     * @param body
     * @param totalFee
     * @param userId
     * @return
     */
    @FormUrlEncoded
    @POST("wechatpay/app/body")
    Observable<BaseResponse<String>> weChatPay(@Field("body") String body, @Field("totalFee") String totalFee,
                                               @Field("userId") String userId);

    /**
     * 提问：发送给医生
     * @param userId
     * @param doctorId
     * @param description
     * @param imgUrl
     * @param area
     * @return
     */
    @FormUrlEncoded
    @POST("inquireRest/add/inquireInfo")
    Observable<BaseResponse<String>> sendInquireInfo(@Field("userId") String userId, @Field("doctorId") String doctorId,
                                         @Field("description") String description, @Field("imgUrl") String imgUrl,
                                         @Field("area") String area);

    /**
     * 医生推荐
     * @param json
     * @return
     */
    @Headers("Content-Type: application/json")
    @POST("patient/apply")
    Observable<BaseResponse<String>> sendDoctorRecommend(@Body RequestBody json);

    /**
     * 获取关注的医生列表
     * @param userId
     * @return
     */
    @GET("user/{userId}/follower")
    Observable<BaseResponse<List<DoctorInfo>>> getFollower(@Path("userId") String userId);

    /**
     * 消息列表
     * @param userId
     * @param pageSize
     * @param pageNum
     * @return
     */
    @GET("user/{userId}/notice")
    Observable<BaseResponse<String>> getNoticeList(@Path("userId") String userId, @Query("pageSize") int pageSize,
                                                   @Query("pageNum") int pageNum);

    /**
     * 发送消息
     * @param message
     * @return
     */
    @FormUrlEncoded
    @POST("user/{userId}/message")
    Observable<BaseResponse<String>> sendMessage(@Path("userId") String userId, @Field("message") String message);

    /**
     * 获取消息(客服)
     * @param userId
     * @param pageSize
     * @param pageNum
     * @return
     */
    @GET("user/{userId}/message")
    Observable<BaseResponse<String>> getMessage(@Path("userId") String userId, @Query("pageSize") int pageSize,
                                                @Query("pageNum") int pageNum);

    /**
     * 查询医生的回复
     * @param inquireId
     * @param pageSize
     * @param pageNum
     * @return
     */
    @GET("inquireAnswerRest/list/inquireAnswer")
    Observable<BaseResponse<String>> getAnswerRest(@Query("inquireId") String inquireId, @Query("pageSize") int pageSize,
                                                                  @Query("pageNum") int pageNum);

    /**
     * 发送回复给医生
     * @param userId
     * @param inquireId
     * @param context
     * @return
     */
    @FormUrlEncoded
    @POST("inquireAnswerRest/add/inquireAnswer")
    Observable<BaseResponse<String>> sendReplyMessage(@Field("userId") String userId, @Field("inquireId") String inquireId,
                                                      @Field("context") String context);

    /**
     * 患者选择预约时间
     * @param url
     * @param json
     * @return
     */
    @Headers("Content-Type: application/json")
    @POST
    Observable<BaseResponse<AppointInfo>> postAppoint(@Url String url, @Body RequestBody json);

    /**
     * 更新预约状态
     * @param url
     * @return
     */
    @GET
    Observable<BaseResponse<String>> getAppointingById(@Url String url);

    /**
     * 支付成功后，主动更新预约状态
     * @param url
     * @return
     */
    @GET
    Observable<BaseResponse<String>> getAppointingSuccess(@Url String url);

    /**
     * 我的报告
     * @param userId
     * @return
     */
    @GET("connect/list_by_user/{userId}")
    Observable<BaseResponse<List<ReportInfo>>> getListByUser(@Path("userId") String userId);

    /**
     * 版本更新
     * @return
     */
    @GET("http://47.97.17.240:8080/Agreement/version.json")
    Call<ResponseBody> getVersion();
}
